package cn.edu.hitwh.resume.biz.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.edu.hitwh.resume.biz.service.ResumeService;
import cn.edu.hitwh.resume.biz.vo.ResumeVo;
import cn.edu.hitwh.resume.dal.dao.DisireDao;
import cn.edu.hitwh.resume.dal.dao.EducationDao;
import cn.edu.hitwh.resume.dal.dao.ProjectExperienceDao;
import cn.edu.hitwh.resume.dal.dao.SeekerDao;
import cn.edu.hitwh.resume.dal.dao.SelfDescDao;
import cn.edu.hitwh.resume.dal.dao.SkillDao;
import cn.edu.hitwh.resume.dal.dao.WorkExperienceDao;

@Service
public class ResumeServiceImpl implements ResumeService {
	
	@Autowired
	SeekerDao seekerDao;
	@Autowired
	EducationDao euducationDao;
	@Autowired
	WorkExperienceDao workExperienceDao;
	@Autowired
	ProjectExperienceDao projectExperienceDao;
	@Autowired
	SelfDescDao selfDescDao;
	@Autowired
	SkillDao skillDao;
	@Autowired
	DisireDao disireDao;

	@Override
	public ResumeVo findBySeekerId(Integer seekerId) {
		ResumeVo resume = new ResumeVo();
		resume.setSeeker(this.seekerDao.retriveById(seekerId));
		resume.setEducationLst(this.euducationDao.retriveBySeekerId(seekerId));
		resume.setWorkExperienceLst(this.workExperienceDao.retriveBySeekerId(seekerId));
		resume.setProjectExperienceLst(this.projectExperienceDao.retriveBySeekerId(seekerId));
		resume.setSelfDescLst(this.selfDescDao.retriveBySeekerId(seekerId));
		resume.setSkillLst(this.skillDao.retriveBySeekerId(seekerId));
		resume.setDisireLst(this.disireDao.retriveBySeekerId(seekerId));
		return resume;
	}

	@Override
	public List<ResumeVo> findAll() {
		List<ResumeVo> resumeLst = new ArrayList<ResumeVo>();
		this.seekerDao.retrive()
			.forEach(seeker -> {
				ResumeVo resume = new ResumeVo();
				resume.setSeeker(seeker);
				resume.setEducationLst(this.euducationDao.retriveBySeekerId(seeker.getId()));
				resume.setWorkExperienceLst(this.workExperienceDao.retriveBySeekerId(seeker.getId()));
				resume.setProjectExperienceLst(this.projectExperienceDao.retriveBySeekerId(seeker.getId()));
				resume.setSelfDescLst(this.selfDescDao.retriveBySeekerId(seeker.getId()));
				resume.setSkillLst(this.skillDao.retriveBySeekerId(seeker.getId()));
				resume.setDisireLst(this.disireDao.retriveBySeekerId(seeker.getId()));
				resumeLst.add(resume);
			});
		return resumeLst;
	}

}
